I'm Alex Kearney, a PhD student studying Computer Science at the University of Alberta. I focus on Artificial Intelligence and Epistemology.
Working on my garden.
New sensors to keep a watch over my plants.
1. Make a copy of the DHCP configuration file
Always make a copy of system files that you are editing. If your changes don't work the way you expect, you can always roll back to the safe, stable, starting state you began at. This allows you to try again without creating a number of inter-dependant changes.
sudo cp /etc/dhcpcd.conf /etc/dhcpcd.conf.save
2. Find the current IP address of your device
On unix devices (Macs, Raspberry pis, etc.) you can check your current IP with Hostname -I
.
3. Find the IP address of your router and your Domain Name Server
To find the router's address:
ip r | grep default
.
To find the Domain Name Server's address:
grep "nameserver" /etc/resolv.conf
These are typically the same address for a home network.
Why add /24? Check out this discussion on subnet masks
4. Edit the DHCP configuration file
At the end of the file add a block where each of the variables are replaced with the values we previously found:
interface wlan0
static ip_address=<device_ip>/24
static routers=<router_ip>
static domain_name_servers=<domain_name_server_ip>
This sets a static IP for the wireless lan, or wlan0
interface on your device. If you want to also set the ethernet interface, add the exact same block again, but change wlan0
to eth0
.
5. Reboot!
sudo reboot
And you're done!
If it didn't work out, you can always revert your changes by running:
sudo cp /etc/dhcpcd.conf.save /etc/dhcpcd.conf
You've got a raspberry pi. Maybe it's a pi 2 or 3 that doesn't have a wifi chip. You bought a USB dongle and plugged it in, but you can't manage to get it to go. The driver that came with the dongle doesn't compile for raspberry pis, and nothing on the pi forums works.
Here's a quick guide for installing the RT8812 driver onto your pi.
1. Get the source kernel installer:
sudo wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source && sudo chmod +x /usr/bin/rpi-source && /usr/bin/rpi-source -q --tag-update
2. Install bc, a maths package:
sudo apt-get install bc
3. Install the kernel:
rpi-source
4. Fetch the driver by cloning it:
git clonehttps://github.com/Kongaloosh/rtl8821CU
note: this repo points to an 8821 driver. If you need another kind of driver, maybe start with a different repo. You should be able to change the configuration of this repo to suit your needs.
There are now three non-standard things you need to do in order for the driver to work with both your pi and the dongle you've purchased:
a. Figure out the dongle's Manufacturer and product ID.
b. Modify the makefile to specify the dongle the driver is for.
c. tweak the driver makefile to suit the pi
Plug the wifi dongle into the pi and run lsusb
to check out what's been plugged into your pi. For instance, when I run it, it looks something like this:
Bus 001 Device 004: ID 0bda:c811 Realtek Semiconductor Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
look at device 04; this is my wifi dongle. If you're having difficulty figuring out which device it is, unplug your dongle and run lsusb
again. whichever device disappeared is your dongle! This is the dongle that I purchased.
Take note of the last four digits of the ID. The ID for my dongle is 0bda:c811
, so in my case it's c811
.
I now know two things about my dongle: the manufacturer (Realtek Semiconductor Corp) and the product ID (c811).
Open os_dep/linux/usb_intf.c
using your favourite editor (i.e., nano, vim)
# ifdef CONFIG_RTL8812A
/*=== Realtek demoboard ===*/
{USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8812), .driver_info = RTL8812},
{USB_DEVICE(USB_VENDER_ID_REALTEK, 0xc811), .driver_info = RTL8821}, # my driver!
{USB_DEVICE(USB_VENDER_ID_REALTEK, 0x881A), .driver_info = RTL8812},
You might be lucky. When you look in the file, you may find that there's already a line describing your dongle! If that's so, mosey on to the next step.
If like me, you're not so lucky, you now need to add the usb device you want the driver to interface with in this file. Each section will be prefaced with an ifdef CONFIG_RTLXXXXx
. These define the interfaces for each section. They match the interface with the appropriate driver. In this case, I added the driver
open up Make
with your favourite editor and change two lines
CONFIG_PLATFORM_I386_PC = y
CONFIG_PLATFORM_ARM_RPI = n
so that they now read
CONFIG_PLATFORM_I386_PC = n
CONFIG_PLATFORM_ARM_RPI = y
This tells the driver to build for our raspberry pi.
Having modified `usb_intf.c
and Make
, we can continue business-as-usual compiling the driver.
5. Make sure we can run the installation script:
sudo chmod +x install.sh
6. Run the installation script:
./install.sh
7. Load our new module into the linux kernel:
sudo insmod 8812au.ko
sudo cp 8812au.ko /lib/modules/$(uname -r)/kernel/drivers/net/wireless
8. Generate a dependency description:
sudo depmod
You should now be done!!! You can verify this by running iwconfig
, which should produce an output like so:
wlan0 IEEE 802.11AC ESSID:"Kongaloosh" Nickname:"<WIFI@REALTEK>"
Mode:Managed Frequency:5.765 GHz Access Point: C4:04:15:10:86:75
Bit Rate:434 Mb/s Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Power Management:off
Link Quality=84/100 Signal level=52/100 Noise level=0/100
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
which means your wireless lan is working! Congratulations.
You need to fetch the headers again. There are links below to forum discussions that cover the topic of headers and missing libraries.
Check to make sure that you added your usb interface properly to usb_intf.c
. Make sure that you ran things in the correct order. Check to see if you're getting error messages that you missed.
If you've been following other tutorials, and made changes to your pi already, it may behoove you to make a clean install and start from scratch.